home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!sisyphus.demon.co.uk
- From: Dave.Sparks@sisyphus.demon.co.uk
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: PPC compilers
- Date: Sun, 7 Jan 96 22:52:20 +0000 (GMT)
- Organization: to be supplied
- Message-ID: <19960107.533250.14585@sisyphus.demon.co.uk>
- References: <john.hendrikx.40ka@grafix.xs4all.nl> <jasonb.820051107@cs.uwa.edu.au> <4c9i2l$h3i@sunsystem5.informatik.tu-muenchen.de> <4ck47h$g07@maureen.teleport.com> <19960106.4EE928.CF59@sisyphus.demon.co.uk> <4cokkg$415@maureen.teleport.com>
- X-NNTP-Posting-Host: sisyphus.demon.co.uk
- In-reply-to: sschaem@teleport.com's message of 7 Jan 1996 14:16:48 GMT
- X-Attribution: DaveS
- Content-Length: 3696
- X-Lines: 90
- X-Mail2News-Path: relay-4.mail.demon.net!post.demon.co.uk!sisyphus.demon.co.uk
-
- >>>>> "SS" == Stephan Schaem <sschaem@teleport.com> writes:
-
- SS> Dave.Sparks@sisyphus.demon.co.uk wrote:
- >> >>>>> "SS" == Stephan Schaem <sschaem@teleport.com> writes:
-
- >> SS> I cant see how people can write code without knowing what data or
- >> SS> type they manipulate...
-
- >> Real-world programmers do it all the time. If you ever want to
-
- SS> So you do math operation without knowing that your destination need
- SS> to be a float or a 2 byte int?
-
- Yes. This is a trivial example of polymorphism.
-
- >> join us, you'll have to learn to do it too. One of many examples
-
- SS> Real world = commercial? I'm deep in it, thanks
-
- Is your employer happy that you're so out of touch with modern
- programming practices?
-
- >> is the ANSI C definition of the 'clock' function: the value returned
- >> is of type 'clock_t', which is defined in a system-dependent header
- >> file. SAS/C defines 'clock_t' to be an unsigned 32-bit value, but
- >> other implementations can (and do) define it to be signed or even
- >> 64-bit floating-point. Since the C arithmetic operations (add,
- >> subtract, multiply, divide) are overloaded (can be used on values of
- >> ...
-
- SS> ANSI for good reason decided on a minimal size of all its basic
- SS> type. This to help you the program choose the right type for your
- SS> need.
-
- SS> The only way you dont care is if you typedef all the ANSI type.
-
- SS> So you created a structure to hold clock value with ulong? now
- SS> recompile this on the system using a clock size of 64bit... where did
- SS> the upper 32bit goes... you know have code that is broken.
-
- I know better than to declare a value as unsigned long when I'm
- going to assign a clock_t to it. And if I did, I'd lose the
- fractional part of a floating-point clock_t, not the upper 32 bits.
-
- SS> ex of something that wont break with a recompile:
-
- SS> typedef short point2d
-
- SS> struct RECTANGLE { point2d x1; point2d y1; point2d x2;
- SS> point2d y2; } rectangle, *rectangle;
-
- SS> then you declare you variable using rectangle, or point2d
-
- SS> Then if later you find out in your design you need to use long (Or
- SS> create another set of include for another platform), you can just
- SS> chnage point2d... I rarely see that done... anyway
-
- So you don't know that many fields in the UNIX header files have
- changed from 16 bits to 32 (for example the user-id and group-id
- in the directory-handling structures)? You have led a sheltered life.
-
- SS> ...
-
- SS> about loop counter size... should I use ulong and forget about it,
- SS> or use ushort to be sure of optimal speed on my target CPU and
- SS> remember my declaration type in case I want to use it for a loop
- SS> count bigger then 65535?. (this result in a sub/bcc vs dbcc encoding
- SS> on 680x0... )
-
- target CPU? How quaint ...
-
- And why use subq/bcc rather than dbcc, if speed is all-important?
- It's easy enough to decrement and check the upper word whenever
- the lower word has just expired, so why assume that a compiler
- will generate the slower code? In any case, if you're using the
- loop counter to index an array, the compiler will probably have
- transformed the loop counter and be subtracting the size of an
- array element, to avoid the use of a (slow) multiply instruction in the
- body of the loop; it couldn't use dbcc anyway. You don't get
- optimal speed by optimizing the instructions, but by optimizing
- the algorithm.
-
- --
- Dave.Sparks@sisyphus.demon.co.uk (Staffordshire, England)
-
- ... details are more implementation-dependant than defined.
-
- --
- UNIX is a registered trademark in the United States and other
- countries, licensed exclusively through X/Open Company Limited
-
-
-